import {Component, OnInit} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {ModelinfoService} from '../../home/service/modelinfoService';

@Component({
    selector: 'app-three-dimensional',
    templateUrl: './three-dimensional.page.html',
    // styleUrls: ['./three-dimensional.page.less'],
})
export class ThreeDimensionalPage implements OnInit {
    showDemo = true;
    iframeHeight;

    // 测试用3D模型url
    modelUrl = '';
    // modelUrl = 'https://3dweb.sv3d.cn:443/webgl/viewsvlx.jsp?id=OTViYzdkM2ItYjIzNS00YWI2LThlMTYtMTkxY2Y3NTM3NzZi&lng=zh';
    // modelUrl = 'http://10.110.84.139:10002/?objpath=http://10.110.91.121:28888/group1/M00/00/01/rBMAAV_4I7SAYNEnAJFDMy1vzn4102.obj&mtlpath=http://10.110.91.121:28888/group1/M00/00/01/rBMAAV_4I7OAU9AsAAAnSdtIek8322.mtl';
    objpath;
    mtlpath;

    constructor(
        private router: Router,
        private activateInfo: ActivatedRoute,
        public modelinfoService: ModelinfoService,
    ) {
        // 获取路由参数
        activateInfo.queryParams.subscribe(queryParams => {
            console.log('3D页面接收到的参数 queryParams = ', queryParams);
            if (JSON.stringify(queryParams) !== '{}') {
                // this.modelUrl = modelinfoService.fastdfsUrl + queryParams.url;
                this.objpath = queryParams.objpath;
                this.mtlpath = queryParams.mtlpath;
                this.modelUrl = 'http://10.110.84.139:10002/?objpath=' + modelinfoService.fastdfsUrl + this.objpath + '&mtlpath=' + modelinfoService.fastdfsUrl + this.mtlpath;
            }
            console.log('modelUrl = ', this.modelUrl);
            console.log('objpath = ', this.objpath);
            console.log('mtlpath = ', this.mtlpath);
        });
    }

    ngOnInit() {
        this.iframeHeight = (document.body.clientHeight - 80 - 44) + 'px';
    }


}
